home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / New System Software Extensions / OpenDoc A6 / OpenDoc Parts Framework / OPF / OS / FWGraphx / Sources / FWTxtShp.cpp < prev    next >
Encoding:
Text File  |  1994-04-21  |  18.7 KB  |  661 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWTxtShp.cpp
  4. //    Release Version:    $ 1.0d1 $
  5. //
  6. //    Creation Date:        3/28/94
  7. //
  8. //    Copyright:    © 1993, 1994 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #ifndef FWTXTSHP_H
  13. #include "FWTxtShp.h"
  14. #endif
  15.  
  16. #ifndef FWSHAPE_H
  17. #include "FWShape.h"
  18. #endif
  19.  
  20. #ifndef FWGC_H
  21. #include "FWGC.h"
  22. #endif
  23.  
  24. #ifndef FWDFAULT_H
  25. #include "FWDfault.h"
  26. #endif
  27.  
  28. #ifndef FWGRUTIL_H
  29. #include "FWGrUtil.h"
  30. #endif
  31.  
  32. #ifndef FWRECSHP_H
  33. #include "FWRecShp.h"
  34. #endif
  35.  
  36. #ifndef FWOVLSHP_H
  37. #include "FWOvlShp.h"
  38. #endif
  39.  
  40. #ifndef FWRRCSHP_H
  41. #include "FWRRcShp.h"
  42. #endif
  43.  
  44. #ifndef FWARCSHP_H
  45. #include "FWArcShp.h"
  46. #endif
  47.  
  48. #ifndef FWLINSHP_H
  49. #include "FWLinShp.h"
  50. #endif
  51.  
  52. #ifndef FWRGNSHP_H
  53. #include "FWRgnShp.h"
  54. #endif
  55.  
  56. // ----- OS Includes -----
  57.  
  58. #ifndef FWMEMMGR_H
  59. #include <FWMemMgr.h>
  60. #endif
  61.  
  62. // ----- OpenDoc Includes -----
  63.  
  64. #ifndef _TRNSFORM_
  65. #include <Trnsform.h>
  66. #endif
  67.  
  68. // ----- Macintosh Includes -----
  69.  
  70. #if defined(FW_BUILD_MAC) && !defined(mathRoutinesIncludes)
  71. #include <math routines.h>
  72. #endif
  73.  
  74. //==============================================================================
  75. //    •• RunTime Info
  76. //==============================================================================
  77.  
  78. #ifdef FW_BUILD_MAC
  79. #pragma segment fwgraphx
  80. #endif
  81.  
  82. //==============================================================================
  83. //    •• class FW_CTextShape
  84. //==============================================================================
  85.  
  86. //------------------------------------------------------------------------------
  87. // FW_CTextShape::FW_CTextShape
  88. //------------------------------------------------------------------------------
  89.  
  90. FW_CTextShape::FW_CTextShape() :
  91.     FW_CShape()
  92. {
  93. }
  94.  
  95. //------------------------------------------------------------------------------
  96. // FW_CTextShape::FW_CTextShape
  97. //------------------------------------------------------------------------------
  98.  
  99. FW_CTextShape::FW_CTextShape(long byteCount,  const char* text, 
  100.                              const FW_CPoint& position,
  101.                               FW_TextAlignment textAlignment) :
  102.     FW_CShape()
  103. {
  104.     SetRep(new FW_CTextShapeRep(byteCount, text, position, textAlignment));
  105. }
  106.  
  107. //------------------------------------------------------------------------------
  108. // FW_CTextShape::FW_CTextShape
  109. //------------------------------------------------------------------------------
  110.  
  111. FW_CTextShape::FW_CTextShape(const FW_CString& string, 
  112.                             const FW_CPoint& position,
  113.                               FW_TextAlignment textAlignment) :
  114.     FW_CShape()
  115. {
  116.     SetRep(new FW_CTextShapeRep(string, position, textAlignment));
  117. }
  118.  
  119. //------------------------------------------------------------------------------
  120. // FW_CTextShape::FW_CTextShape
  121. //------------------------------------------------------------------------------
  122.  
  123. FW_CTextShape::FW_CTextShape(const FW_CTextShape& other) :
  124.     FW_CShape(other)
  125. {
  126. }
  127.  
  128. //------------------------------------------------------------------------------
  129. // FW_CTextShape::FW_CTextShape
  130. //------------------------------------------------------------------------------
  131.  
  132. FW_CTextShape::FW_CTextShape(FW_CTextShapeRep* rep) :
  133.     FW_CShape(rep)
  134. {
  135. }
  136.  
  137. //------------------------------------------------------------------------------
  138. // FW_CTextShape::operator=
  139. //------------------------------------------------------------------------------
  140.  
  141. FW_CTextShape& FW_CTextShape::operator=(const FW_CTextShape& other)
  142. {
  143.     SetRep(other.GetRep());
  144.     return *this;
  145. }
  146.  
  147. //------------------------------------------------------------------------------
  148. // FW_CTextShape::operator=
  149. //------------------------------------------------------------------------------
  150.  
  151. FW_CTextShape& FW_CTextShape::operator=(FW_CTextShapeRep* other)
  152. {
  153.     SetRep(other);
  154.     return *this;
  155. }
  156.  
  157. //------------------------------------------------------------------------------
  158. // FW_CTextShape::operator FW_CRectShape
  159. //------------------------------------------------------------------------------
  160.  
  161. FW_CTextShape::operator FW_CRectShape() const
  162. {    
  163.     FW_CRectShape rectShape(((FW_CShapeRep*)GetRep())->GetShapeBounds());
  164.     rectShape->SetShapeFill(((FW_CShapeRep*)GetRep())->GetShapeFill());
  165.     return rectShape;
  166. }
  167.  
  168. //------------------------------------------------------------------------------
  169. // FW_CTextShape::operator FW_COvalShape
  170. //------------------------------------------------------------------------------
  171.  
  172. FW_CTextShape::operator FW_COvalShape() const
  173. {    
  174.     FW_COvalShape ovalShape(((FW_CShapeRep*)GetRep())->GetShapeBounds());
  175.     ovalShape->SetShapeFill(((FW_CShapeRep*)GetRep())->GetShapeFill());
  176.     return ovalShape;
  177. }
  178.  
  179. //------------------------------------------------------------------------------
  180. // FW_CTextShape::operator FW_CRoundRectShape
  181. //------------------------------------------------------------------------------
  182.  
  183. FW_CTextShape::operator FW_CRoundRectShape() const
  184. {    
  185.     FW_CRoundRectShape roundRectShape(((FW_CShapeRep*)GetRep())->GetShapeBounds(), FW_kZeroPoint);
  186.     roundRectShape->SetShapeFill(((FW_CShapeRep*)GetRep())->GetShapeFill());
  187.     return roundRectShape;
  188. }
  189.  
  190. //------------------------------------------------------------------------------
  191. // FW_CTextShape::operator FW_CArcShape
  192. //------------------------------------------------------------------------------
  193.  
  194. FW_CTextShape::operator FW_CArcShape() const
  195. {    
  196.     FW_CArcShape arcShape(((FW_CShapeRep*)GetRep())->GetShapeBounds(), 0, 0);
  197.     arcShape->SetShapeFill(((FW_CShapeRep*)GetRep())->GetShapeFill());
  198.     return arcShape;
  199. }
  200.  
  201. //------------------------------------------------------------------------------
  202. // FW_CTextShape::operator FW_CLineShape
  203. //------------------------------------------------------------------------------
  204.  
  205. FW_CTextShape::operator FW_CLineShape() const
  206. {    
  207.     FW_CPoint start, end;
  208.     start = ((FW_CTextShapeRep*)GetRep())->GetPosition();
  209.     end.y = start.y;
  210.     
  211.     FW_CRect bounds = ((FW_CShapeRep*)GetRep())->GetShapeBounds();
  212.     end.x = bounds.right - ((FW_CShapeRep*)GetRep())->GetPenSize();
  213.     
  214.     FW_CLineShape lineShape(start, end);
  215.     lineShape->SetShapeFill(((FW_CShapeRep*)GetRep())->GetShapeFill());
  216.     return lineShape;
  217. }
  218.  
  219. //------------------------------------------------------------------------------
  220. // FW_CTextShape::operator FW_CRegionShape
  221. //------------------------------------------------------------------------------
  222.  
  223. FW_CTextShape::operator FW_CRegionShape() const
  224. {    
  225.     FW_CRegionShape regionShape(((FW_CShapeRep*)GetRep())->GetShapeBounds());
  226.     regionShape->SetShapeFill(((FW_CShapeRep*)GetRep())->GetShapeFill());
  227.     return regionShape;
  228. }
  229.  
  230. //==============================================================================
  231. //    •• class FW_CTextShapeRep
  232. //==============================================================================
  233.  
  234. //------------------------------------------------------------------------------
  235. //    • FW_CTextShapeRep::FW_CTextShapeRep
  236. //------------------------------------------------------------------------------
  237.  
  238. FW_CTextShapeRep::FW_CTextShapeRep() :
  239.     FW_CShapeRep(gGraphicGlobales.gText),
  240.     fByteCount(0),
  241.     fText(NULL),
  242.     fPosition(0, 0),
  243.     fTextAlignment(FW_kBaseLine)
  244. {
  245. }
  246.  
  247. //------------------------------------------------------------------------------
  248. //    • FW_CTextShapeRep::FW_CTextShapeRep
  249. //------------------------------------------------------------------------------
  250.  
  251. FW_CTextShapeRep::FW_CTextShapeRep(long byteCount, const char* text, 
  252.                                     const FW_CPoint& position,
  253.                                       FW_TextAlignment textAlignment) :
  254.     FW_CShapeRep(gGraphicGlobales.gText),
  255.     fByteCount(byteCount),
  256.     fText(NULL),
  257.     fPosition(position),
  258.     fTextAlignment(textAlignment)
  259. {
  260.     if (text == NULL)
  261.         fByteCount == 0;
  262.         
  263.     if (fByteCount != 0)
  264.     {
  265.         fText = (char*)FW_CMemoryManager::AllocateBlock(byteCount);
  266.         FW_CMemoryManager::CopyMemory(text, fText, byteCount);
  267.     }
  268. }
  269.  
  270. //------------------------------------------------------------------------------
  271. //    • FW_CTextShapeRep::FW_CTextShapeRep
  272. //------------------------------------------------------------------------------
  273.  
  274. FW_CTextShapeRep::FW_CTextShapeRep(const FW_CString& string, 
  275.                                     const FW_CPoint& position,
  276.                                       FW_TextAlignment textAlignment) :
  277.     FW_CShapeRep(gGraphicGlobales.gText),
  278.     fByteCount(string.GetByteLength()),
  279.     fText(NULL),
  280.     fPosition(position),
  281.     fTextAlignment(textAlignment)
  282. {
  283.     if (fByteCount != 0)
  284.     {
  285.         fText = (char*)FW_CMemoryManager::AllocateBlock(fByteCount);
  286.         FW_CMemoryManager::CopyMemory((const char*)string, fText, fByteCount);
  287. //        string.Export(fText);
  288.     }
  289. }
  290.  
  291. //------------------------------------------------------------------------------
  292. //    • FW_CTextShapeRep::~FW_CTextShapeRep
  293. //------------------------------------------------------------------------------
  294.  
  295. FW_CTextShapeRep::~FW_CTextShapeRep()
  296. {
  297. }
  298.  
  299. //------------------------------------------------------------------------------
  300. //    • FW_CTextShapeRep::CalcTextPosition
  301. //------------------------------------------------------------------------------
  302.  
  303. FW_SPlatformPoint FW_CTextShapeRep::CalcTextPosition(FW_CGraphicContext* graphicContext,
  304.                                                     const FW_CPoint& position,
  305.                                                     FW_TextAlignment textAlignment)
  306. {
  307.     FW_CPoint tempPt(position);
  308.  
  309. #ifdef FW_BUILD_MAC    
  310.     FontInfo fi;
  311.     switch (textAlignment)
  312.     {
  313.         case FW_kAscentLine:
  314.             ::GetFontInfo(&fi);
  315.             tempPt.y += ff(fi.ascent);
  316.             break;
  317.             
  318.         case FW_kBaseLine:
  319.             break;
  320.             
  321.         case FW_kDescentLine:
  322.             ::GetFontInfo(&fi);
  323.             tempPt.y -= ff(fi.descent + fi.leading);
  324.             break;
  325.     }
  326. #endif
  327.  
  328.     return graphicContext->AsPlatformPoint(tempPt);
  329. }
  330.  
  331. //------------------------------------------------------------------------------
  332. //    • FW_CTextShapeRep::Draw
  333. //------------------------------------------------------------------------------
  334.  
  335. void FW_CTextShapeRep::Draw(FW_CGraphicContext* graphicContext)
  336. {    
  337.     FW_ShapeFills shapeFill = GetShapeFill();
  338.     
  339.     if (shapeFill == FW_kNullShape || fText == NULL)
  340.         return;
  341.         
  342.     graphicContext->SelectInkAndStyle(GetShapeInk(), GetShapeStyle(), FW_kTypographicShape, shapeFill);
  343.  
  344.     FW_SPlatformPoint position = CalcTextPosition(graphicContext, fPosition, fTextAlignment);
  345.     
  346. #ifdef FW_BUILD_MAC
  347.     ::MoveTo(position.h, position.v);
  348.     ::DrawText(fText, 0, fByteCount);
  349. #endif
  350.  
  351. #ifdef FW_BUILD_WIN
  352. #endif
  353. }
  354.  
  355. //------------------------------------------------------------------------------
  356. //    • FW_CTextShapeRep::Draw
  357. //------------------------------------------------------------------------------
  358.  
  359. void FW_CTextShapeRep::Draw(FW_CGraphicContext* graphicContext, 
  360.                              const FW_CRect& box, 
  361.                              FW_Justification justification)
  362. {    
  363.     FW_ShapeFills shapeFill = GetShapeFill();
  364.     
  365.     if (shapeFill == FW_kNullShape || fText == NULL)
  366.         return;
  367.         
  368.     graphicContext->SelectInkAndStyle(GetShapeInk(), GetShapeStyle(), FW_kTypographicShape, shapeFill);
  369.  
  370. #ifdef FW_BUILD_MAC
  371.     FontInfo theFontInfo;
  372.     XMPCoordinate widthOfString;
  373.     XMPCoordinate boxWidth;
  374.     FW_CRect localBox = box;
  375.  
  376.     ::GetFontInfo(&theFontInfo);
  377.     widthOfString = ff(::TextWidth(fText, 0, fByteCount));
  378.     boxWidth = localBox.right - localBox.left;
  379.     if (widthOfString < boxWidth)
  380.     {
  381.         switch (justification)
  382.         {
  383.             case FW_kFlushLeft:
  384.             case FW_kFlushDefault:
  385.                 break;
  386.  
  387.             case FW_kFlushCenter:
  388.                 localBox.left += (boxWidth - widthOfString) / 2;
  389.                 break;
  390.  
  391.             case FW_kFlushRight:
  392.                 localBox.left += boxWidth - widthOfString;
  393.                 break;
  394.         }
  395.     }
  396.  
  397.     localBox.top += ff(theFontInfo.ascent) + (((localBox.bottom - localBox.top) - ff(theFontInfo.ascent + theFontInfo.descent + theFontInfo.leading)) /  2) ;
  398.     FW_SPlatformPoint qdPos = graphicContext->AsPlatformPoint(localBox[FW_kTopLeft]);
  399.     ::MoveTo(qdPos.h, qdPos.v);
  400.     ::DrawText(fText, 0, fByteCount);
  401. #endif
  402. #ifdef FW_BUILD_WIN
  403. #endif
  404. }
  405.  
  406. //------------------------------------------------------------------------------
  407. //    • FW_CTextShapeRep::DrawText
  408. //------------------------------------------------------------------------------
  409.  
  410. void FW_CTextShapeRep::DrawText(FW_CGraphicContext* graphicContext, 
  411.                                 long byteCount, 
  412.                                 const char* text, 
  413.                                 const FW_CPoint& position,
  414.                                   FW_TextAlignment textAlignment)
  415. {    
  416.     if (text == NULL || byteCount == 0 || gGraphicGlobales.gText.fFill == FW_kNullShape)
  417.         return;
  418.         
  419.     graphicContext->SelectInkAndStyle(gGraphicGlobales.gText.fInk, gGraphicGlobales.gText.fStyle, FW_kTypographicShape, gGraphicGlobales.gText.fFill);
  420.  
  421.     FW_SPlatformPoint pos = FW_CTextShapeRep::CalcTextPosition(graphicContext, position, textAlignment);
  422.  
  423. #ifdef FW_BUILD_MAC
  424.     ::MoveTo(pos.h, pos.v);
  425.     ::DrawText(text, 0, byteCount);
  426. #endif
  427. #ifdef FW_BUILD_WIN
  428. #endif
  429. }
  430.  
  431. //------------------------------------------------------------------------------
  432. //    • FW_CTextShapeRep::DrawString
  433. //------------------------------------------------------------------------------
  434.  
  435. void FW_CTextShapeRep::DrawString(FW_CGraphicContext* graphicContext, 
  436.                                     const FW_CString& string, 
  437.                                     const FW_CPoint& position,
  438.                                       FW_TextAlignment textAlignment)
  439. {    
  440.     if (string.GetByteLength() == 0 || gGraphicGlobales.gText.fFill == FW_kNullShape)
  441.         return;
  442.         
  443.     graphicContext->SelectInkAndStyle(gGraphicGlobales.gText.fInk, gGraphicGlobales.gText.fStyle, FW_kTypographicShape, gGraphicGlobales.gText.fFill);
  444.  
  445.     FW_SPlatformPoint pos = CalcTextPosition(graphicContext, position, textAlignment);
  446.  
  447. #ifdef FW_BUILD_MAC
  448.     ::MoveTo(pos.h, pos.v);
  449.     ::DrawText(string, 0, string.GetByteLength());
  450. #endif
  451. }
  452.  
  453. //------------------------------------------------------------------------------
  454. //    • FW_CTextShapeRep::Transform
  455. //------------------------------------------------------------------------------
  456.  
  457. void FW_CTextShapeRep::Transform(XMPTransform* transform)
  458. {
  459.     fPosition = transform->TransformPoint(fPosition);
  460. }
  461.  
  462. //------------------------------------------------------------------------------
  463. //    • FW_CTextShapeRep::InverseTransform
  464. //------------------------------------------------------------------------------
  465.  
  466. void FW_CTextShapeRep::InverseTransform(XMPTransform* transform)
  467. {
  468.     fPosition = transform->InvertPoint(fPosition);
  469. }
  470.  
  471. //------------------------------------------------------------------------------
  472. //    • FW_CTextShapeRep::MoveShape
  473. //------------------------------------------------------------------------------
  474.  
  475. void FW_CTextShapeRep::MoveShape(XMPCoordinate deltaX, XMPCoordinate deltaY)
  476. {
  477.     fPosition.x += deltaX;
  478.     fPosition.y += deltaY;
  479. }
  480.  
  481. //------------------------------------------------------------------------------
  482. //    • FW_CTextShapeRep::MoveShapeTo
  483. //------------------------------------------------------------------------------
  484.  
  485. void FW_CTextShapeRep::MoveShapeTo(XMPCoordinate x, XMPCoordinate y)
  486. {
  487.     fPosition.x = x;
  488.     fPosition.y= y;
  489. }
  490.  
  491. //------------------------------------------------------------------------------
  492. //    • FW_CTextShapeRep::GetShapeBounds
  493. //------------------------------------------------------------------------------
  494.  
  495. FW_CRect FW_CTextShapeRep::GetShapeBounds() const
  496. {
  497.     FW_CRect rect(0,0,0,0);
  498.     
  499.     if (fByteCount != 0)
  500.     {
  501. #ifdef FW_BUILD_MAC
  502.         GrafPtr svPort;
  503.         
  504.         ::GetPort(&svPort);
  505.         ::SetPort(gGraphicGlobales.gScratchWindow);
  506.         
  507.         TextStyle textStyle;
  508.         GetMacTextStyle(textStyle);
  509.         ::SetPortTextStyle(textStyle);
  510.         
  511.         FontInfo fi;
  512.         ::GetFontInfo(&fi);
  513.         
  514.         long width = ::TextWidth(fText, 0, fByteCount);
  515.         
  516.         rect.left = fPosition.x;
  517.         rect.right = fPosition.x + ff(width);
  518.         
  519.         switch (fTextAlignment)
  520.         {
  521.             case FW_kAscentLine:
  522.                 rect.top = fPosition.y;
  523.                 rect.bottom = rect.top + ff(fi.ascent + fi.descent + fi.leading);
  524.                 break;
  525.             case FW_kBaseLine:
  526.                 rect.top = fPosition.y - ff(fi.ascent);
  527.                 rect.bottom = rect.top + ff(fi.descent + fi.leading);
  528.                 break;
  529.             case FW_kDescentLine:
  530.                 rect.bottom = fPosition.y;
  531.                 rect.top = rect.bottom - ff(fi.ascent + fi.descent + fi.leading);
  532.                 break;
  533.         }
  534.             
  535.         ::SetPort(svPort);
  536. #endif
  537.  
  538. #ifdef FW_BUILD_WIN
  539.     NotYetImplemented();
  540. #endif
  541.     }    
  542.  
  543.     return rect;
  544. }
  545.  
  546. //------------------------------------------------------------------------------
  547. //    • FW_CTextShapeRep::Copy
  548. //------------------------------------------------------------------------------
  549.  
  550. FW_CTextShape FW_CTextShapeRep::Copy() const
  551. {
  552.     // fText will be copied
  553.     FW_CTextShape text(fByteCount, fText, fPosition, fTextAlignment);
  554.     return text;
  555. }
  556.  
  557. //------------------------------------------------------------------------------
  558. //    • FW_CTextShapeRep::GetText
  559. //------------------------------------------------------------------------------
  560.  
  561. long FW_CTextShapeRep::GetText(char* text) const
  562. {
  563.     if (fText == NULL)
  564.         return 0;
  565.     
  566.     FW_CMemoryManager::CopyMemory(fText, text, fByteCount);
  567.     return fByteCount;
  568. }
  569.  
  570. //------------------------------------------------------------------------------
  571. //    • FW_CTextShapeRep::SetText
  572. //------------------------------------------------------------------------------
  573.  
  574. void FW_CTextShapeRep::SetText(long byteCount, const char* text)
  575. {
  576.     if (text == NULL)
  577.         byteCount = 0;
  578.  
  579.     fByteCount = byteCount;
  580.     if (fText)
  581.         FW_CMemoryManager::FreeBlock(fText);
  582.     
  583.     
  584.     if (fByteCount != 0)
  585.     {
  586.         fText = (char*)FW_CMemoryManager::AllocateBlock(byteCount);
  587.         FW_CMemoryManager::CopyMemory(text, fText, byteCount);
  588.     }
  589.     
  590.     Changed();
  591. }
  592.  
  593. //------------------------------------------------------------------------------
  594. //    • FW_CTextShapeRep::SetAsDefault
  595. //------------------------------------------------------------------------------
  596.  
  597. void FW_CTextShapeRep::SetAsDefault() const
  598. {
  599.     SetDefaultProperties(gGraphicGlobales.gText);
  600. }
  601.  
  602. //------------------------------------------------------------------------------
  603. //    • FW_CTextShapeRep::HitTest
  604. //------------------------------------------------------------------------------
  605.  
  606. FW_HitTestPart FW_CTextShapeRep::HitTest(const FW_CPoint& test) const
  607. {
  608.     return FW_kOutside;
  609. }
  610.  
  611. //------------------------------------------------------------------------------
  612. //    • FW_CTextShapeRep::GetMacTextStyle
  613. //------------------------------------------------------------------------------
  614.  
  615. void FW_CTextShapeRep::GetMacTextStyle(TextStyle& textStyle) const
  616. {
  617.     XMPCoordinate textSize;
  618.     GetShapeStyle()->GetMacFontInfo(textStyle.tsFont, textStyle.tsFace, textSize);
  619.     textStyle.tsSize = FixedToInt(textSize);
  620.     
  621.     FW_CColor color;
  622.     GetShapeInk()->GetForeColor(&color);
  623.     textStyle.tsColor = color;
  624. }
  625.  
  626. //----------------------------------------------------------------------------------------
  627. //    • FW_CTextShapeRep::Flatten
  628. //----------------------------------------------------------------------------------------
  629.  
  630. void FW_CTextShapeRep::Flatten(FW_CWritableStream& stream)
  631. {
  632.     fPosition.Flatten(stream);
  633.     stream.Write((char*)&fTextAlignment, sizeof(fTextAlignment));
  634.     stream << fByteCount;
  635.     stream.Write(fText, fByteCount);
  636. }
  637.  
  638. //----------------------------------------------------------------------------------------
  639. //    • FW_CTextShapeRep::Unflatten
  640. //----------------------------------------------------------------------------------------
  641.  
  642. void FW_CTextShapeRep::Unflatten(FW_CReadableStream& stream)
  643. {
  644.     if (fText)
  645.     {
  646.         ::DisposePtr((char*)fText);
  647.         fText = NULL;
  648.     }
  649.     fByteCount = 0;
  650.  
  651.     fPosition.Unflatten(stream);
  652.     stream.Read((char*)&fTextAlignment, sizeof(fTextAlignment));
  653.     stream >> fByteCount;
  654.     
  655.     if (fByteCount != 0)
  656.     {
  657.         fText = (char*)::NewPtr(fByteCount);
  658.         stream.Read(fText, fByteCount);
  659.     }
  660. }
  661.